import request from '@/utils/request'
export const userCode = data => {
  return request({
    method: 'post',
    url: 'v1_0/authorizations',
    data
  })
}
export const verCode = data => {
  return request({
    method: 'get',
    url: 'v1_0/sms/codes/' + data
  })
}
export const user = () => request({
  method: 'GET',
  url: '/v1_0/user'
  // 发送请求头数据

})
export const getUserChannels = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}
// 获取文章列表信息接口
export const getListAPI = params => {
  return request({
    method: 'get',
    url: '/v1_1/articles',
    // per_page: perpage
    params
  })
}
// 获取全部列表文档
export const channelsAPI = () => {
  return request({
    method: 'get',
    url: '/v1_0/channels'
  })
}
// 添加用户频道
export const EditChannelsAPI = (channel) => {
  return request({
    method: 'patch',
    url: '/v1_0/user/channels',
    data: {
      channels: [channel]
    }

  })
}
// 删除用户收藏列表
export const DeleteChannelAPI = params => {
  return request({
    method: 'delete',
    url: '/v1_0/user/channels/' + params
  })
}
// 搜索联想
export const getSearchSuggestions = params => {
  return request({
    url: '/v1_0/suggestion',
    params
  })
}
// 搜索结果
export const getSearchResult = params => {
  return request({
    url: '/v1_0/search',
    params
  })
}
// 获取文章列表详情
export const getArticleAPI = articleId => {
  return request({
    url: `/v1_0/articles/${articleId}`
  })
}
/**
 * 关注用户
 */
export const addFollow = target => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}

/**
 * 取消关注用户
 */
export const deleteFollow = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${target}`
  })
}
/**
 * 收藏文章
 */
export const addCollect = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

/**
 * 取消收藏文章
 */
export const deleteCollect = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`
  })
}
